/******************************************************************************/
//	DxAnim2D.h	-	ANIMATIONS!
//
//	Author:		Russell Klinkerman
//	Created:	01.17.2004
/******************************************************************************/

#ifndef _DXANIM2D_H_
#define _DXANIM2D_H_

// Forward Declare the image class
class	CDxImage;

// the animation class
class	CDxAnim2D
{
	private:

		CDxImage	*	pSourceImage;	// The image containing the frames for this animation

		unsigned int	uiRows,			// Number of rows in source image
						uiColumns,		// Number of columns in source image

						uiStartIndex,	// Starting index for this animation
						uiFrameCount,	// Number of frames in this animation
						uiCurrentFrame,	// The animation's current frame

						uiFrequency;	// The frequency (in ms) for changing frames

		RECT			rSource;		// The source image rectangle containing the
										// current frame

		enum AnimationFlags
		{
			ANIM_PLAYING = 1<<0,	// Flag indicating if the animation is playing
			ANIM_LOOPING = 1<<1,	// Flag indicating if the animation is looping
		};

		unsigned int	uiFlags;	// Defines flags associated with this animation

	public:

		// constructor
		CDxAnim2D() : uiFlags(0) {}

		// destructor
		~CDxAnim2D() {}

		/******************************************************************************/
		//	Set	-	Sets all needed information for an animation
		//
		//	In:		_pSourceImage	-	The image containing the animation frames
		//			_uiRows			-	Number of rows in source image
		//			_uiColumns		-	Number of columns in source image
		//			_uiStartIndex	-	The index at which the frames for this anim begin
		//			_uiFrameCount	-	The number of frames in this animation
		//			_uiFrequency	-	The frequency (in ms) at which frames change
		//			_bLoop			-	Flag indicating if the animation should loop
		/******************************************************************************/
		void	Set(CDxImage*	_pSourceImage, unsigned int _uiRows, unsigned int _uiColumns,
						unsigned int _uiStartIndex, unsigned int _uiFrameCount,
							unsigned int _uiFrequency, bool _bLoop = true);

		/******************************************************************************/
		//	Update	-	Updates Animation
		/******************************************************************************/
		void	Update();

		/******************************************************************************/
		//	Draw	-	Draws the current frame of the animation to the backbuffer
		//
		//	In:		_pMatrix	-	Matrix defining position, scale, and rotation
		//							for drawing
		//
		//			_bSpriteDrawInProgress	-	Indicates if D3D is currently in
		//										the mode for drawing sprites.
		/******************************************************************************/
		void	Draw(D3DXMATRIX	*	_pMatrix, bool _bSpriteDrawInProgress = false);

};

#endif